{% extends "base.html" %}

{% block content %}
<script language="javascript" src="/static/js/jquery-1.2.1.pack.js" type="text/javascript"></script>
<script language=javascript>
function changestatus(e,id,cfm,back)
	{
	  if (confirm(cfm))
		{
		$.post("/v2/classes/changeclassstatus/",{id:id,value:$(e).val()},function(data){
		if(data == "ok")
		{
			alert('ok');
		}
		if(data != "ok")
		{
		alert(data);
		$(e).val(back);
		}});
		}
	else
	$(e).val(back);
	}

function verify(form){
  if(form.name.value==""){
	alert("Enter the name please!");
	form.name.focus();		
       return false;
	}
  if(form.intro.value==""){
	alert("Enter the introduce please!");
	form.intro.focus();		
       return false;
	}
  if(form.imvalue.value==""){
	alert("请输入项目优先级,数值越大越优先!");
	form.imvalue.focus();		
       return false;
	}
	return true;
 }

</script>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<form name='form1' id='form1' action="/save_pj/" method='post' onsubmit='return verify(this);'>
<table width='95%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center"> </td></tr>
<tr valign='middle' align='left'><td class='odd' width='100%'>
		{%for p in p_list%}
		<span class="tab-back" id="mix-tab"><a href="/v2/classes/?pid={{p.id}}">{%if p_obj.id == p.id %}<font color='red'><b>{{p.name}}</b></font>{%else%}{{p.name}}{%endif%}</a></span>
		{%endfor%}
</td></tr>
<tr valign='middle' align='left'><td class='odd' width='100%'>
<select name="courseid" id="courseid" onChange="window.location='/v2/classes/?pid={{p_obj.id}}&courseid='+this.options[this.selectedIndex].value">>
<option value="0">Select Please</option>
{%for c in c_list%}
<option value="{{c.id}}" {%if courseid == c.id %}selected{%endif%}>{{c.period}}</option>
{%endfor%}
</select>
</td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
<table width='95%' class='grid' cellspacing='1' align='center'>
  <tr valign='middle' align='left'>
  <td class='odd' width='10%'>Period</td>
  <td class='even' width='20%'>Modules</td>
  <td class='odd' width='10%'>C/E</td>
  <td class='even' width='20%'>Class Date</td>
  <td class='odd' width='10%'>Lecture</td>
  <td class='even' width='20%'>Textbook</td>
  <td class='odd' width='10%'>Venue</td>
  </tr>
  <tr valign='middle' align='left'>
  <td class='odd' width='13%'>&nbsp;{{mp_obj.period}}</td>
  <td class='even' width='17%'>{{mp_obj.modules}}</td>
  <td class='odd' width='10%'>{{mp_obj.core_elective}}</td>
  <td class='even' width='20%'>Day 1: {{mp_obj.class_start}}<br>
  Day 1: {{mp_obj.class_end}}<br>
	{%if mp_obj.class_date3%} Day 3: {{mp_obj.class_date3}}{%endif%}<br>
	{%if mp_obj.class_date4%} Day 4: {{mp_obj.class_date4}}{%endif%}<br>
	{%if mp_obj.class_date5%} Day 5: {{mp_obj.class_date5}}{%endif%}<br>
  </td>
  <td class='odd' width='10%'>{{mp_obj.lecture}}</td>
  <td class='even' width='20%'>{{mp_obj.textbook}}</td>
  <td class='odd' width='10%'>{{mp_obj.venue}}</td>
  </tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
<table width='95%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">Class Student List</td></tr>
<tr valign='middle' align='left'></tr>
  <tr valign='middle' align='left'>
  <td class='odd' width='30'>id</td>
  <td class='odd' width='15%'>Student Name</td>
  <td class='even' width='20%'>Email</td>
  <td class='odd' width='40%'>Address</td>
  <td class='even' width='15%'>Tel.#</td>
  <td class='odd' width='10%'>Status <a href="/v2/classes/setallcompleted/?pid={{p_obj.id}}&courseid={{courseid}}" onclick="return confirm('Are you sure to set all this class students to be completed?');"><font color='red'>Completed</font></a></td>
  </tr>
  {% for s in s_list %}
 
  <tr valign='middle' align='left'>
  <td class='order_id odd'></td>
  <td class='odd'>{{s.student.fullname}}</td>
   <td class='even'>{{s.student.email}}</td>
   <td class='odd'>{%if s.student.address%}{{s.student.address}}{%else%}{{s.student.officeaddress}}{%endif%}</td>
   <td class='even'>H:{{s.student.tel_h}} <br>O:{{s.student.tel_o}} <br>M:{{s.student.tel_m}}</td>
   <td class='odd'>
    <select name="status" id="status" onchange="changestatus(this,{{s.id}}, 'are you sure?','{{s.status}}')">
	<option value="Waived" {%if s.status == 'Waived'%}selected{%endif%}>Waived</option>
	<option value="Defer" {%if s.status == 'Defer'%}selected{%endif%}>Defer</option>
	<option value="Completed"  {%if s.status == 'Completed'%}selected{%endif%}>Completed</option>
	<option value="Upcoming"  {%if s.status == 'Upcoming'%}selected{%endif%}>Upcoming</option>
	<option value="Studied"  {%if s.status == 'Studied'%}selected{%endif%}>Studied</option>
	<option value="Taiwan"  {%if s.status == 'Taiwan'%}selected{%endif%}>Taiwan</option>
	<option value="NA"  {%if s.status == 'NA'%}selected{%endif%}>NA</option>
	<option value="Online"  {%if s.status == 'Online'%}selected{%endif%}>Online</option>
	</select>
   </td>
  </tr>

  {% endfor %}

      <tr><td  class='even' colspan="10" align="right">
{% if is_paginated %}
                    {% ifequal current_page 1 %}first 
                    {% else %} <a href="/pjlist">first</a>
                    {% endifequal %}
                    {% if has_previous %} <a href="/pjlist/{{ previous_page }}/">prev</a>
                    {% else %} prev
                    {% endif %}
                    {% if has_next %}<a href="/pjlist/{{ next_page }}/">next</a>
                    {% else %}next
                    {% endif %}
                    {% ifequal current_page pages %}last
                    {% else %} <a href="/pjlist/{{ pages }}/">last</a>
                    {% endifequal %}
                    &nbsp;&nbsp;
                    Current：{{ current_page }}/{{ pages }}&nbsp;&nbsp;
                {% endif %}              
               {{countstudent}} Records 
</td></tr>
</table>
<script>
(function(){
	var i=1;
	$('td.order_id').each(function(){
		$(this).text(i++)
	})	
})()
</script>
{% endblock %}